home *** CD-ROM | disk | FTP | other *** search
/ PC World 2006 November / PCWorld_2006-11_cd.bin / system / innosetup / isetup-5.1.8.exe / {app} / Examples / CodeDll.iss (.txt) < prev    next >
Encoding:
Inno Setup Script  |  2006-10-03  |  1.7 KB  |  42 lines

  1. ; -- CodeDll.iss --
  2. ; This script shows how to call DLL functions at runtime from a [Code] section.
  3. [Setup]
  4. AppName=My Program
  5. AppVerName=My Program version 1.5
  6. DefaultDirName={pf}\My Program
  7. DisableProgramGroupPage=yes
  8. UninstallDisplayIcon={app}\MyProg.exe
  9. OutputDir=userdocs:Inno Setup Examples Output
  10. [Files]
  11. Source: "MyProg.exe"; DestDir: "{app}"
  12. Source: "MyProg.chm"; DestDir: "{app}"
  13. Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme
  14. Source: "MyDll.dll"; Flags: dontcopy
  15. [Code]
  16. const
  17.   MB_ICONINFORMATION = $40;
  18. //importing a Windows API function
  19. function MessageBox(hWnd: Integer; lpText, lpCaption: String; uType: Cardinal): Integer;
  20. external 'MessageBoxA@user32.dll stdcall';
  21. //importing a custom DLL function
  22. procedure MyDllFunc(hWnd: Integer; lpText, lpCaption: String; uType: Cardinal);
  23. external 'MyDllFunc@files:MyDll.dll stdcall';
  24. //importing a function for a DLL which might not exist at runtime
  25. procedure DelayLoadedFunc(hWnd: Integer; lpText, lpCaption: String; uType: Cardinal);
  26. external 'DllFunc@DllWhichMightNotExist.dll stdcall delayload';
  27. function NextButtonClick(CurPage: Integer): Boolean;
  28.   hWnd: Integer;
  29. begin
  30.   if CurPage = wpWelcome then begin
  31.     hWnd := StrToInt(ExpandConstant('{wizardhwnd}'));
  32.     MessageBox(hWnd, 'Hello from Windows API function', 'MessageBoxA', MB_OK or MB_ICONINFORMATION);
  33.     MyDllFunc(hWnd, 'Hello from custom DLL function', 'MyDllFunc', MB_OK or MB_ICONINFORMATION);
  34.     try
  35.       //if this DLL does not exist (it shouldn't), an exception will be raised
  36.       DelayLoadedFunc(hWnd, 'Hello from delay loaded function', 'DllFunc', MB_OK or MB_ICONINFORMATION);
  37.     except
  38.       //handle missing dll here
  39.     end;
  40.   end;
  41.   Result := True;
  42.